<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #e9ecef;
        }
        .home-container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        .home-container h2 {
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
<div class="home-container">
    <h2>欢迎来到主页</h2>
    <p>您已成功登录。</p>
    <button onclick="logout()">注销</button>
</div>

<script>
    function logout() {
        // 清除存储的token
        localStorage.removeItem('token');
        // 跳转回登录页面
        window.location.href = '/login.html';
    }

    // 检查是否已登录
    document.addEventListener('DOMContentLoaded', (event) => {
        const token = localStorage.getItem('token');
        if (!token) {
            alert('您尚未登录，请登录后访问主页。');
            window.location.href = '/login.html';
        }
    });
</script>
</body>
</html>
